import config from './config.js';

export default {
    getDailyNews() {
        return new Promise((resolve, reject) => {
            uni.request({
                url: 'https://v3.alapi.cn/api/zaobao',
                data: {
                    token: config.token,
                    format: 'json'
                },
                success: (res) => {
                    if (res.data.code === 200) {
                        resolve(res.data.data);
                    } else {
                        reject(new Error('Failed to fetch news'));
                    }
                },
                fail: (err) => {
                    reject(err);
                }
            });
        });
    }
};